package com.yeqian.user.handle;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.authentication.logout.LogoutHandler;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author yeqian
 * @Classname 注销处理
 * @Description TODO
 * @Date 2021/5/8 16:17
 */
@Component
public class YeqLogoutHandler implements LogoutHandler {
    @Override
    public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
        if (!StringUtils.isEmpty(request.getHeader("Authorization"))){
            SecurityContextHolder.clearContext();
        }

    }
}
